﻿using System;
using System.Reflection;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using MethodWorx.CMS.TemplateParser.Installer;
using MethodWorx.Core.DomainModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MethodWorx.CMS.Providers;
using Moq;
using MethodWorx.CMS.Content;

namespace MethodWorx.CMS.TemplateParser.Tests.Installer
{
    [TestClass]
    public class TerraFirmaMasterTemplateTests
    {
        [TestMethod]
        public void EnsureMasterTemplateIsCreated()
        {
            /*var provider = new Mock<ICmsDataProvider>();
            var uowFactory = new StubUnitOfWorkFactory();
            var pageTemplateRepository = new Mock<IPageTemplateRepository>();
            var contentTemplateRepository = new Mock<IContentTemplateRepository>();
            var pageTemplate = new PageTemplate();
            pageTemplateRepository.Setup(p => p.CreateEntityInstance()).Returns(pageTemplate).Verifiable();
            pageTemplateRepository.Setup(p => p[pageTemplate.Id]).Returns(pageTemplate).Verifiable();

            provider.Setup(p => p.GetRepository<IPageTemplateRepository>()).Returns(
                pageTemplateRepository.Object).Verifiable();
            provider.Setup(p => p.GetRepository<IContentTemplateRepository>()).Returns(
                contentTemplateRepository.Object).Verifiable();
            provider.Setup(p => p.GetUnitOfWorkFactory()).Returns(uowFactory).Verifiable();

            using(var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MethodWorx.CMS.TemplateParser.Tests.terrafirma_mastertemplate.zip"))
            {
                var installerEngine = new InstallerEngine(null, stream);
                var parser = installerEngine.GetParser();
                var workflow = parser.GetWorkflowExecutionEngine(provider.Object);

                workflow.Execute();
            }

            provider.Verify();
            pageTemplateRepository.Verify();

            Assert.AreEqual("{name}", pageTemplate.Name);
            Assert.AreEqual("", pageTemplate.Description);
            Assert.IsFalse(string.IsNullOrEmpty(pageTemplate.Template));*/
            
        }
    }
}
